package com.wyl.idempotentcheck.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class R<T> implements Serializable {

    /**
     * 结果编码
     */
    private Integer code;

    /**
     * 结果信息
     */
    private String msg;

    /**
     * 数据
     */
    private T data;

    public static <T> R<T> success(T object) {
        R<T> r = new R<T>();
        r.data = object;
        r.code = Code.SUCCESS.getCode();
        r.msg = Code.SUCCESS.getMsg();
        return r;
    }

    public static <T> R<T> error(String msg) {
        R r = new R();
        r.msg = msg;
        r.code = Code.ERROR.getCode();
        return r;
    }


}
